{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "608bcb4c-9b23-4efe-afe7-7dd402b1710d",
   "metadata": {},
   "outputs": [],
   "source": [
    "from sklearn.datasets import load_breast_cancer\n",
    "from sklearn.svm import SVC\n",
    "from sklearn.model_selection import train_test_split\n",
    "import numpy as np\n",
    "import pandas as pd\n",
    "x,y = load_breast_cancer().data,load_breast_cancer().target\n",
    "print(x,shape)\n",
    "print(x)\n",
    "from sklearn.preprocessing import StandardScaler\n",
    "x = StandardScaler().fit_transform(x)\n",
    "print(x)\n",
    "from sklearn.metrics import accuracy_score\n",
    "x_train,x_test,y_train,y_test=train_test_split(x,y,test_size=0.3,random_state=420)\n",
    "Kernel=[\"linear\",\"poly\",\"rbf\",\"sigmoid\"]\n",
    "for kernel in Kernel:\n",
    "    model = SVC(kernel=kernel,gamma=\"auto\",degree=1)\n",
    "model.fit(x_train,y_train)\n",
    "pred=model.predict(x_test)\n",
    "ac = accuracy_score(y_test,pred)\n",
    "print(\"选择%s核函数时，模型的预测准确率为%f\"%(kernel,ac))"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python [conda env:base] *",
   "language": "python",
   "name": "conda-base-py"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.13.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
